<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>订单</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <script type="text/javascript" src="$!webPath/resources/app/js/Adaptation.js"></script>
    <link rel="stylesheet" type="text/css" href="$!webPath/resources/weixin/css/common.css?v=2017-04-10_142313"/>
    <link rel="stylesheet" type="text/css" href="$!webPath/resources/weixin/css/style.css?v=2017-04-10_142316"/>
    <script type="text/javascript" src="$!webPath/resources/app/js/zepto.min.js"></script>
    <script src="$!webPath/resources/app/js/waputils.js?v=2017-04-08_202946" type="text/javascript"></script>
</head>
<body>

    <div class="conSection aConSection orderSection">
    	<input type="hidden" id="addressId" value="$!addressId">
    	<input type="hidden" id="goodsCartId" value="$!goodsCartId">
    	<input type="hidden" id="storeCartId" value="$!storeCartId">
    	<input type="hidden" id="goodsPrice" value="$!goodsPrice">
    	<input type="hidden" id="is_cardno_check" value="$!goods.is_cardno_check">
        <div class="cYsBx">
            <div class="order-duser">
                <a class="it-info" href="$!webPath/weixin/goods/address.htm?goodsCartId=$!goodsCartId">
                    <div class="it-tt ft30 clearfix">
                    	<span class="fl">
                    		<i class="icon ico-8"></i>$!addressData.receiverName
                    	</span>
                    	<span class="fr"><i class="icon ico-9"></i>$!addressData.mobile</span></div>
                    <div class="ft28 lt44">
                    	$!addressData.provinceName $!addressData.cityName $!addressData.countyName $!addressData.streetName $!addressData.detailAddress
                    </div>
                </a>
                <div class="it-ico"><i class="icon ico-6"></i></div>
            </div>
            #if ("1" == $!goods.is_cardno_check) 
            <div class="order-idcard">
            	<div class="it-tip ft28">*请确定身份证信息与收件人信息一致</div>
                <ul class="ul_0 ft30">
                    <li class="li_0">
                        <div class="li_l">身份证号</div>
                        <div class="li_c"><input id="card_num" type="number" value="$addressData.card_num" /></div>
                    </li>
                </ul>
            </div>
            #end
            <div class="order-dgood">
                <div class="it-tp ft26">$!storeName</div> 
                <div class="it-info clearfix">
                    <div class="it-img"><img src="$!photo.picUrl" onerror="this.src='$!webPath/resources/image/default.png';" /></div>
                    <div class="it-det">
                        <div class="it-tt ft28">$!goods.goods_name</div>
                        <div class="it-des ft22">$!goods.seo_description</div>
                        <div class="it-price ft28 clearfix">
                            <span class="fl it_pxj">￥$!goodsPrice</span>
                            <span class="fl it_pyj ft24">￥$!goods.goods_price_show</span>
                            <span class="fr it_pn">x$!count</span>
                        </div>
                    </div>
                </div>
                <div class="it-freight ft22 clearfix">
                    <span class="fl">运费：</span><span class="fr freight">￥0.00</span>
                </div>
            </div>
            <!-- <div class="order-rmk ft24"><button>点击输入备注</button></div> -->
            <div class="order-rmk">
                <div style="border:1px solid #e5e5e5;">
                <textarea class="ft26" id="t_rmk" style="overflow-y:auto;height:0.88rem;" required placeholder="点击输入备注" onpropertychange="this.style.height = this.scrollHeight + 'px';" oninput="this.style.height= this.scrollHeight+'px';"></textarea>
                <script>document.getElementById("t_rmk").style.height=document.getElementById("t_rmk").scrollHeight+"px";</script>
                </div>
            </div>
        </div>
    </div>

    <div class="ft-fixed-order ft32">
        <span class="it-other"></span>
        <span class="it-price">合计：<b><i class="ft22">￥</i><span id="totalPrice">$!goodsPrice</span></b></span>
        <span class="btn-pay bg_a2e542">付款</span>
    </div>
    <script type="text/javascript">
    	//计算运费
    	var addressId = $("#addressId").val();
    	var goodsCartId = $("#goodsCartId").val();
    	var storeCartId = $("#storeCartId").val();
    	var goodsPrice = $("#goodsPrice").val();
    	var is_cardno_check = $("#is_cardno_check").val();
    	function initFreight() {
			$.get("$!webPath/weixin/address/freight.json?_wo_=$!_openid&addressId=" + addressId + "&goodsCartId=" + goodsCartId, function(result) {
				if ("100" == result.code) {
					var transfee = result.data.transfee;
 					var transfeeShow = result.data.transfeeShow;
 					$(".freight").text("￥" + transfeeShow);
 					var totalPrice = parseFloat(goodsPrice) + parseFloat(transfeeShow);
 					$("#totalPrice").text(totalPrice.toFixed(2));
				}
			});
    	}
    	function initPay() {
    		$(".btn-pay").click(function() {
    		   var storeCartParam={
    	   				goodsCartIds : goodsCartId,
    	   				transType : "express",
    	   				addressId : addressId,
    	   				msg : $("#t_rmk").val()
    	   	   };
    	   	   var params = {};
    	   	   params[storeCartId]=storeCartParam;
      	   	   var useJycoin = 0;
      	   	   var card_num = "";
      	   	   if ("1" == is_cardno_check) {    	   		   
      	   	   	   card_num = $("#card_num").val();
      	   	   	   if (null == card_num || "" == card_num) {
      	   	   	       Utils.showToast("身份证号码不能为空"); 
      	   	   	       return;
      	   	   	   }
      	   	   }
      	   	   
      	   	   $.post("$!webPath/app/order/submits.json", {
      	   	   		"_wo_":"$!_openid",
      	   			"params" : JSON.stringify(params),
      	   			"useJycoin" : useJycoin,	        	   		
      	   			"addressId" : addressId,
      	   			"card_num" : card_num
      	   	   }, function(result) {
      	   		   if ("100" == result.code) {
      	   			 	var orderIds = result.data.orderIds;
  	   			   		var orderFormIds = result.data.orderFormIds
  	   			   		var totalAmount = result.data.totalAmount
  	   			   		
  	   			   		var targetUrl = "$!webPath/app/wx/pay/confirm.htm?orderId=" + orderIds + "&_wo_=$!_openid";
  	   					   
  	   					window.location.replace(targetUrl);
      	   		   } else {
      	   			   Utils.showToast(result.msg); 
      	   		   }
      	   	   })
    		});
    	}
    	$(function() {
    		initFreight();
    		initPay();
    	});
    </script>
    <!--微信分享 -->
	<script type="text/javascript" src="$!webPath/resources/style/app/goodsEvaluation/js/dongsj.js"></script>
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript">
	    dongsjFunc.wxConfig('$!appId', '$!timestamp', '$!nonceStr', '$!signature', false, []);			
		wx.ready(function () {
			dongsjFunc.wxShare({
				title: '$!weixinShare_title',
				desc: '$!weixinShare_desc',
				link: location.href.split("#")[0],
				imgUrl: '$!weixinShare_imgurl'
			});
		}); 
	</script>
	<!--微信分享 -->
</body>
</html>